package com.example.administrator.familfinalcialmanagement.greendao.gen;

import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;

import com.example.administrator.familfinalcialmanagement.bean.ResidueBean;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "RESIDUE_BEAN".
*/
public class ResidueBeanDao extends AbstractDao<ResidueBean, Long> {

    public static final String TABLENAME = "RESIDUE_BEAN";

    /**
     * Properties of entity ResidueBean.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Id = new Property(0, Long.class, "id", true, "_id");
        public final static Property ResidueMoney = new Property(1, String.class, "residueMoney", false, "RESIDUE_MONEY");
        public final static Property ResidueOne = new Property(2, String.class, "residueOne", false, "RESIDUE_ONE");
        public final static Property ResidueTwo = new Property(3, String.class, "residueTwo", false, "RESIDUE_TWO");
        public final static Property ResidueThree = new Property(4, String.class, "residueThree", false, "RESIDUE_THREE");
        public final static Property ResidueFour = new Property(5, String.class, "residueFour", false, "RESIDUE_FOUR");
    }


    public ResidueBeanDao(DaoConfig config) {
        super(config);
    }
    
    public ResidueBeanDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /** Creates the underlying database table. */
    public static void createTable(Database db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"RESIDUE_BEAN\" (" + //
                "\"_id\" INTEGER PRIMARY KEY ," + // 0: id
                "\"RESIDUE_MONEY\" TEXT," + // 1: residueMoney
                "\"RESIDUE_ONE\" TEXT," + // 2: residueOne
                "\"RESIDUE_TWO\" TEXT," + // 3: residueTwo
                "\"RESIDUE_THREE\" TEXT," + // 4: residueThree
                "\"RESIDUE_FOUR\" TEXT);"); // 5: residueFour
    }

    /** Drops the underlying database table. */
    public static void dropTable(Database db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"RESIDUE_BEAN\"";
        db.execSQL(sql);
    }

    @Override
    protected final void bindValues(DatabaseStatement stmt, ResidueBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String residueMoney = entity.getResidueMoney();
        if (residueMoney != null) {
            stmt.bindString(2, residueMoney);
        }
 
        String residueOne = entity.getResidueOne();
        if (residueOne != null) {
            stmt.bindString(3, residueOne);
        }
 
        String residueTwo = entity.getResidueTwo();
        if (residueTwo != null) {
            stmt.bindString(4, residueTwo);
        }
 
        String residueThree = entity.getResidueThree();
        if (residueThree != null) {
            stmt.bindString(5, residueThree);
        }
 
        String residueFour = entity.getResidueFour();
        if (residueFour != null) {
            stmt.bindString(6, residueFour);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, ResidueBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String residueMoney = entity.getResidueMoney();
        if (residueMoney != null) {
            stmt.bindString(2, residueMoney);
        }
 
        String residueOne = entity.getResidueOne();
        if (residueOne != null) {
            stmt.bindString(3, residueOne);
        }
 
        String residueTwo = entity.getResidueTwo();
        if (residueTwo != null) {
            stmt.bindString(4, residueTwo);
        }
 
        String residueThree = entity.getResidueThree();
        if (residueThree != null) {
            stmt.bindString(5, residueThree);
        }
 
        String residueFour = entity.getResidueFour();
        if (residueFour != null) {
            stmt.bindString(6, residueFour);
        }
    }

    @Override
    public Long readKey(Cursor cursor, int offset) {
        return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
    }    

    @Override
    public ResidueBean readEntity(Cursor cursor, int offset) {
        ResidueBean entity = new ResidueBean( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // residueMoney
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // residueOne
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // residueTwo
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // residueThree
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // residueFour
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, ResidueBean entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setResidueMoney(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setResidueOne(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setResidueTwo(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setResidueThree(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setResidueFour(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(ResidueBean entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(ResidueBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(ResidueBean entity) {
        return entity.getId() != null;
    }

    @Override
    protected final boolean isEntityUpdateable() {
        return true;
    }
    
}
